{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "928c6039-6f63-4b5a-8821-2df7a647058e",
   "metadata": {},
   "source": [
    "# ParameterSampler for Randomized Search"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d153468-cb4f-460e-bda1-291f77ecddea",
   "metadata": {},
   "source": [
    "A little template that can be used to create submit scripts based on Randomized Search for arbitrary projects."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "854032e0-f6b9-49cd-af3e-a31b4db5705b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "my_script.py --param1 2.7858767423914466 --param2 categorical1\n",
      "my_script.py --param1 1.7138837047473028 --param2 categorical1\n",
      "my_script.py --param1 2.205259076331565 --param2 categorical2\n",
      "my_script.py --param1 1.964475733730389 --param2 categorical2\n",
      "my_script.py --param1 3.923056793538462 --param2 categorical1\n",
      "my_script.py --param1 2.3187771880904404 --param2 categorical2\n",
      "my_script.py --param1 1.568470072776602 --param2 categorical1\n",
      "my_script.py --param1 2.5092680373504668 --param2 categorical2\n",
      "my_script.py --param1 1.7542889787184976 --param2 categorical2\n",
      "my_script.py --param1 2.779020708741076 --param2 categorical1\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import ParameterSampler\n",
    "from scipy.stats import uniform\n",
    "\n",
    "distributions = dict(param1=uniform(loc=0, scale=4),\n",
    "                     param2=['categorical1', 'categorical2'])\n",
    "\n",
    "sampler = ParameterSampler(distributions, n_iter=10, random_state=123)\n",
    "for param in sampler:\n",
    "    \n",
    "    print(\"my_script.py\", end=\"\")\n",
    "    for k in  param:\n",
    "        print(f' --{k} {param[k]}', end=\"\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a57a7747-814c-48bc-b143-9a624ef1715d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
